home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 1 Issue 2
/
PDCD-1 - Issue 02.iso
/
_utilities
/
utilities
/
001
/
makeapp2
/
!MakeApp2
/
Source
(
.txt
)
< prev
next >
Wrap
RISC OS BBC BASIC V Source
|
1994-09-03
|
12KB
|
484 lines
><MakeApp2$Dir>.Source
This application is FreeWare. (c) 1994 Dick Alstein
Appl$="MakeApp2"
"ApplVersion$="1.00 (3-Sep-94)"
error
quit%=
5mask%=(1<<0)+(1<<4)+(1<<5)+(1<<7)+(1<<11)+(1<<12)
"Wimp_Poll",mask%,blk%
reason%
reason%
(
2 :
"Wimp_OpenWindow",,blk%
)
3 :
"Wimp_CloseWindow",,blk%
?
6 :
mouseclick(blk%!0,blk%!4,blk%!8,blk%!12,blk%!16)
7 :
startsavedialogue
*
8 :
"Wimp_ProcessKey",blk%!24
9 :
menuselect(blk%)
1
17,18 :
receive(blk%!4,blk%!8,blk%!16)
quit%
"Wimp_CloseDown"
tfn$
errblk% &100
"Wimp_Initialise",200,&4B534154,Appl$
osversion%,thistask%
error
scrapblk% 256
blksize%=16*1024
blk% blksize%
indsize%=&200
indir% indsize%
indirend%=indir%+indsize%
ptrinfo% 24
scrapblk%!0=-1
&!scrapblk%!4=0 : scrapblk%!8=0
'%scrapblk%!12=68 : scrapblk%!16=68
scrapblk%!20=&7000301A
$(scrapblk%+24)="!MakeApp2"
"Wimp_CreateIcon",,scrapblk%
baricon%
osversion%<310
,& tfn$="<MakeApp2$Dir>.Templates2"
.% tfn$="<MakeApp2$Dir>.Templates"
"Wimp_OpenTemplate",,tfn$
1"infowin%=
loadtemplate("Info")
2%$(blk%!(92+7*32+20))=ApplVersion$
3%savewin%=
loadtemplate("SaveBox")
4 savefname%=blk%!(92+0*32+20)
5$optwin%=
loadtemplate("Options")
6"outputfname%=blk%!(92+5*32+20)
"Wimp_CloseTemplate"
initmenus
readscreenvars
status_load
selecticon(optwin%,1,preserveargs%)
selecticon(optwin%,3,sameleafname%)
selecticon(optwin%,4,
sameleafname%)
codesize%=&200
armcode% codesize%
loadprologue
dirname(F$)
p%,q%
F$,".",p%)
q% > 0
p%=q%+1
q%=0
F$,p%-2)
errbox(err$,boxes%)
errblk%!0=0
$(errblk%+4)=err$+
"Wimp_ReportError",errblk%,boxes%,Appl$
,click%
=(click%=1)
error
"Wimp_CloseDown" :
errbox(
$+" (line "+
)+")",3)
"Wimp_CloseDown"
fileexists(f$)
type%,flags%
type%=0
(f$)>0
"XOS_File",17,f$
type%;flags%
=(type%=1)
((flags%
1)=0)
filesize(f$)
size%
(f$)>0
"OS_File",17,f$
,,,,size%
=size%
initmenus
"MenuUtil_Initialise",010,0
"MenuUtil_New",,Appl$
mainmenu%
"MenuUtil_Add",mainmenu%,"Info"
item_info%
"MenuUtil_Add",mainmenu%,"Options..."
item_options%
"MenuUtil_Add",mainmenu%,"Quit"
item_quit%
"MenuUtil_SubMenu",item_info%,infowin%
leafname(f$)
p%,q%
p%=q%+1
q%=
f$,".",p%)
q%=0
f$,p%)
loadprologue
fn$,f%
~!fn$="<MakeApp2$Dir>.Prologue"
prologuesize%=
filesize(fn$)
prologue% prologuesize%
"OS_GBPB",4,f%,prologue%,prologuesize%
prologue%?i%<>&FF
4 prologue%?i%=0 :
set the line no. to 0
prologue%?(i%+1)=0
2 i%+=prologue%?(i%+2) :
on to the next line
9prologuesize%=i%-1 :
omit the terminating &0D + &FF
loadtemplate(name$)
handle%
"Wimp_CloseTemplate" :
error
"Wimp_LoadTemplate",,blk%+4,indir%,indirend%,-1,name$,0
,,indir%
"Wimp_CreateWindow",,blk%+4
handle%
=handle%
menuselect(selection%)
"Wimp_GetPointerInfo",,ptrinfo%
selection%!0
openoptionswin
quit%=
(ptrinfo%!8
showmenu(0)
mouseclick(xpos%,ypos%,button%,wndw%,icon%)
wndw%
button%
openoptionswin
showmenu(blk%)
savewin%
icon%
1 :
startsavedrag
optwin%
icon%
) preserveargs%=
preserveargs%
sameleafname%=
sameleafname%=
status_save
scrapblk%!0=optwin%
,
"Wimp_CloseWindow",,scrapblk%
scrapblk%!0=optwin%
,
"Wimp_CloseWindow",,scrapblk%
openoptionswin
dx%,dy%
dx%=0
dy%=0
blk%!0=optwin%
"Wimp_GetWindowState",,blk%
(blk%!32
(1<<16))=0
center window to screen if not already open
. dx%=(screensize_x%-(blk%!12+blk%!4))
. dy%=(screensize_y%-(blk%!16+blk%!8))
blk%!4=blk%!4+dx%
blk%!8=blk%!8+dy%
blk%!12=blk%!12+dx%
blk%!16=blk%!16+dy%
blk%!28=-1
"Wimp_OpenWindow",,blk%
readscreenvars
xeig%,yeig%,xpixels%,ypixels%
"OS_ReadModeVariable",-1,4
,,xeig%
"OS_ReadModeVariable",-1,5
,,yeig%
"OS_ReadModeVariable",-1,11
,,xpixels%
"OS_ReadModeVariable",-1,12
,,ypixels%
Escreensize_x%=(xpixels%+1)*(1<<xeig%) :
screen size in OS units
)screensize_y%=(ypixels%+1)*(1<<yeig%)
receive(sender%,ref%,code%)
ack%,icon%,window%,fname$,ftype%,fsize%,hlp$
ack%=0
sender% <> thistask%
code%
0 : quit%=
$ outputfname$=
str(blk%+44)
startconversion
"
"Wimp_CreateMenu",,-1
ack%=3
window%=blk%!20
icon%=blk%!24
fname$=
str(blk%+44)
ftype%=blk%!40
(ftype%=&FFB)
inputfname$=fname$
inputfsize%=blk%!36
sameleafname%
2 $(savefname%)=
leafname(inputfname$)
+ $(savefname%)=$(outputfname%)
scrapblk%!0=savewin%
/
"Wimp_GetWindowState",,scrapblk%
.
"Wimp_GetPointerInfo",,ptrinfo%
-
(window%=-2)
(icon%=baricon%)
> xpos%=ptrinfo%!0-((scrapblk%!12-scrapblk%!4)
/ ypos%=96+scrapblk%!16-scrapblk%!8
> xpos%=ptrinfo%!0-((scrapblk%!12-scrapblk%!4)
> ypos%=ptrinfo%!4+((scrapblk%!16-scrapblk%!8)
6
"Wimp_CreateMenu",,savewin%,xpos%,ypos%
&400C1
readscreenvars
ack%<>0
blk%!0=256
blk%!12=ref%
blk%!16=ack%
-
"Wimp_SendMessage",17,blk%,sender%
selecticon(window%,icon%,f%)
scrapblk%!0=window%
scrapblk%!4=icon%
scrapblk%!8=1<<21
scrapblk%!8=0
scrapblk%!12=1<<21
"Wimp_SetIconState",,scrapblk%
iconselected(window%,icon%)
scrapblk%!0=window%
scrapblk%!4=icon%
"Wimp_GetIconState",,scrapblk%
#=((scrapblk%!24)
(1<<21)) > 0
shadeicon(window%,icon%,f%)
scrapblk%!0=window%
scrapblk%!4=icon%
scrapblk%!8=(1<<22)
scrapblk%!8=0
scrapblk%!12=1<<22
"Wimp_SetIconState",,scrapblk%
showmenu(blkptr%)
"MenuUtil_Show",mainmenu%,blkptr%
startsavedialogue
dragasprite%
"DragASprite_Stop"
blk%!0=64
blk%!12=0
blk%!16=1
"Wimp_GetPointerInfo",,ptrinfo%
blk%!20=ptrinfo%!12
blk%!24=ptrinfo%!16
blk%!28=ptrinfo%!0
blk%!32=ptrinfo%!4
blk%!36=inputfsize%
blk%!40=&FF8
;*$(blk%+44)=
leafname($(savefname%))+
"Wimp_SendMessage",17,blk%,ptrinfo%!12,ptrinfo%!16
startsavedrag
b%,win0x%,win0y%
scrapblk%!0=savewin%
"Wimp_GetWindowState",,scrapblk%
C#win0x%=scrapblk%!4-scrapblk%!20
D$win0y%=scrapblk%!16-scrapblk%!24
scrapblk%!0=savewin%
scrapblk%!4=1
"Wimp_GetIconState",,scrapblk%
blk%!4=5
blk%!8=scrapblk%!8+win0x%
blk%!12=scrapblk%!12+win0y%
blk%!16=scrapblk%!16+win0x%
blk%!20=scrapblk%!20+win0y%
"Wimp_GetPointerInfo",,ptrinfo%
blk%!24=blk%!8-ptrinfo%!0
blk%!28=blk%!12-ptrinfo%!4
P,blk%!32=screensize_x%+blk%!16-ptrinfo%!0
Q,blk%!36=screensize_y%+blk%!20-ptrinfo%!4
"OS_Byte",161,&1C
,,b%
dragasprite%=(b%
2)<>0
dragasprite%
"DragASprite_Start",&A1,1,"file_ff8",blk%+8,blk%+24
"Wimp_DragBox",1,blk%
status_default
preserveargs%=
sameleafname%=
$(outputfname%)="!RunImage"
status_load
ofn$
d#F%=
("<MakeApp2$Dir>.Options")
F%=0
status_default
#F% :
error :
status_default :
#F%,preserveargs%,sameleafname%,ofn$
$(outputfname%)=ofn$
status_save
q#F%=
("<MakeApp2$Dir>.Options")
#F% :
error :
#F%,preserveargs%,sameleafname%,$(outputfname%)
str(s%)
i%,n$
(s%?i%>=32)
(i%<255)
n$+=
(s%?i%)
i%+=1
startconversion
fi%,fo%,bytesnotread%
)inputfilesize%=
filesize(inputfname$)
assemble
inputfname$
inputfname$=outputfname$
fo%=
"<Wimp$Scrap>"
fo%=
outputfname$
(fi%<>0)
(fo%<>0)
"OS_GBPB",2,fo%,code_start,(program_start-code_start)
preserveargs%
2
"OS_GBPB",2,fo%,prologue%,prologuesize%
copy original program to output
;
"OS_GBPB",4,fi%,blk%,blksize%
,,,bytesnotread%
8
"OS_GBPB",2,fo%,blk%,(blksize%-bytesnotread%)
inputfname$=outputfname$
+
"OS_File",18,"<Wimp$Scrap>",&FF8
5
"Copy <Wimp$Scrap> "+inputfname$+" ~C D F "
)
"OS_File",18,outputfname$,&FF8
assemble
LR=14
PC=15
preserveargs%
/ programsize%=prologuesize%+inputfilesize%
! programsize%=inputfilesize%
dblquote$=
pass%=8
P%=armcode%
L%=armcode%+codesize%
[ OPT pass%
.code_start
# ; copy Basic program to &9000
LDR R1,program_size
LDR R2,program_end
LDR R3,program_dest
.copyabyte
LDRB R0,[R2],#-1
STRB R0,[R3],#-1
SUBS R1,R1,#1
BNE copyabyte
preserveargs%
[ OPT pass%
" ; construct new command line
G SWI "OS_GetEnv" ; get pointer to original command line
ADR R2,newcmdline_rest
O.copyachar ; copy first part (=name of the Absolute file)
LDRB R1,[R0],#1
3 TEQ R1,#0 ; stop if at zero
1 TEQNE R1,#
(" ") ; or if at a space
STRNEB R1,[R2],#1
BNE copyachar
D MOV R3,#
(dblquote$) ; file name goes between doublequotes
STRB R3,[R2],#1
B MOV R3,#
(" ") ; and is always followed by a space
STRB R3,[R2],#1
M TEQ R1,#0 ; if at zero then skip back to read it again
! SUBEQ R0,R0,#1
Q.copytailchar ; copy rest of command line (=arguments, if any)
LDRB R1,[R0],#1
STRB R1,[R2],#1
TEQ R1,#0
BNE copytailchar
+ ; create environment variable from it
ADR R0,varname
ADR R1,newcmdline
O SUB R2,R2,R1 ; length of string, including terminating zero
MOV R3,#0
A MOV R4,#4 ; variable type = literal string
SWI "OS_SetVarVal"
[ OPT pass%
; enter Basic
ADR R0,cmdline
SWI "OS_CLI"
.program_size
EQUD programsize%
.program_end
= EQUD &8000+(program_start-code_start)+programsize%-1
.program_dest
" EQUD &9000+programsize%-1
.cmdline
& EQUS "Basic -quit @00009000,"
.cmdline_endaddr
3 EQUS
"00000000"+
~(&9000+programsize%),8)
EQUS
preserveargs%
[ OPT pass%
.varname
EQUS "MakeApp2$CLI"
EQUS
.newcmdline
& EQUS "Basic -quit "+dblquote$
Q.newcmdline_rest ; to be filled in after(!!) Basic program has been moved
[ OPT pass%
K.program_start ; in the file, Basic program (+prologue) goes here
.code_end
pass%